package com.zyz.M_File和IO流.IO流.节点流.InputStream和OutputStream;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author: vick
 * @Date: 2025/4/8
 * @Description:
 * @version: 1.0
 */
public class Demo5 {
    public static void main(String[] args) throws IOException {
        //1. 创建File对象
        File file = new File("fox.txt");
        //2. 创建 流对象
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        //将字符串转成字节数组
        byte[] bytes = "abcdefg".getBytes();
        fileOutputStream.write(bytes);
        //从索引2开始，3个字节
        fileOutputStream.write(bytes, 2, 3);
        //关闭资源文件
        fileOutputStream.close();
    }
}
